// node let_demo01.js
// npx babel-node let_demo01.js

let _ = '';
const {log} = console;

let test01 = function(){
    _ = (typeof window !== 'undefined' 
        ? window 
        : (typeof process === 'object'
            && typeof require === 'function'
            && typeof global === 'object')
            ? global
            : this);
    log(_);
};

// test01();

let test02 = function(){
    let getGlobal = function(){
        if (typeof self !== 'undefined') { return self; }
        if (typeof window !== 'undefined') { return window; }
        if (typeof global !== 'undefined') { return global; }
        throw new Error('unable to locate global object');
    };

    _ = getGlobal();
    log(_);
};

test02();

